<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用Velcity库进行动画化</title>
    <script type="text/javascript" src="https://vuejs.org/js/vue.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js"></script>
</head>
<body>

<div id="app">
    <button @click="taxiCalled=true">打车</button>
    <button @click="taxiCalled=false">取消</button>
    <transition @enter="enter" @leave="leave" :css="false">
        <p v-if="taxiCalled">🚗</p>
    </transition>

</div>

<script type="text/javascript">
    new Vue({
        el: '#app',
        data: {
            taxiCalled: false
        },
        methods:{
            enter (el, done) {
                Velocity(el,
                    { opacity: [1, 0], translateX: ["0px", "200px"] },
                    { duration: 2000, easing: "ease-out", complete: done })
            },
            leave (el, done) {
                Velocity(el,
                    { opacity: [0, 1], 'font-size': ['0.1em', '1em'] },
                    { duration: 200, complete: done})
            }
        }
    })
</script>

</body>
</html>